


package com.UMLife.me.ui;

import javax.microedition.lcdui.Image;
import com.UMLife.me.action.AboutMeAction;
import de.enough.polish.ui.Container;
import de.enough.polish.ui.Form;
import de.enough.polish.ui.ImageItem;
import de.enough.polish.ui.Item;
import de.enough.polish.ui.StringItem;





public class AboutMeUI
		extends Form
{
	public AboutMeUI()
	{
		
		//#style AboutMeUI
		super(null);
		try
		{
			//TODO 这个经常使用的logo已经采用Global的方式实现了。这里把它简化一下。
			Image logoImage = Image.createImage("/logo.png");
			this.logo = new ImageItem(null, logoImage, Item.PLAIN, null);
			
		} catch (Exception e)
		{
			// TODO: handle exception
		}
		//#style nameItem
		StringItem nameItem = new StringItem("用户名：", this.name, Item.PLAIN);
		//#style nameItem
		StringItem mailItem = new StringItem("邮箱：", this.mail, Item.PLAIN);
		//#style nameItem
		StringItem phoneItem = new StringItem("手机号码：", this.phone, Item.PLAIN);
		//#style nameItem
		StringItem scoreItem = new StringItem("成绩：", Integer
				.toString(this.score), Item.PLAIN);
		//#style nameItem
		StringItem rankItem = new StringItem("排名：",
				Integer.toString(this.rank), Item.PLAIN);
		//#style AboutMeCon
		Container con = new Container(true);
		con.add(scoreItem);
		con.add(rankItem);
		try
		{
			Image buttonImageOk = Image.createImage("/buttonOK.png");
			//#style button
			this.buttonOk = new ImageItem(null, buttonImageOk, Item.BUTTON,
					null);
			
		} catch (Exception e)
		{
			// TODO: handle exception
			e.printStackTrace();
		}
		//#style record
		StringItem recordOk = new StringItem("获奖记录：", "恭喜你！你已经获得了"
				+ Integer.toString(this.award) + "次奖", Item.PLAIN);
		try
		{
			Image buttonImageNot = Image.createImage("/buttonNot.png");
			//#style button
			this.buttonNot = new ImageItem(null, buttonImageNot, Item.BUTTON,
					null);
			
		} catch (Exception e)
		{
			// TODO: handle exception
			e.printStackTrace();
		}
		//#style record
		StringItem recordNot = new StringItem("获奖记录：", "赶紧加油吧！获取你的第一份奖品",
				Item.PLAIN);
		this.append(this.logo);
		this.append(nameItem);
		this.append(mailItem);
		this.append(phoneItem);
		this.append(con);
		if (this.Awardable)
		{
			this.append(this.buttonOk);
			this.append(recordOk);
		}
		else
		{
			this.append(this.buttonNot);
			this.append(recordNot);
		}
		AboutMeAction action = new AboutMeAction(this, this.buttonOk);
		this.setCommandListener(action);
		
	}
	
	/**
	 * 设置获奖次数
	 * 
	 * @param a
	 */
	public void setAward(int a)
	{
		//TODO
		this.award = a;
	}
	
	/**
	 * 是否可以兑换奖品
	 * 
	 * @param isAwarded
	 */
	public void setAwardable(boolean isAwarded)
	{
		//TODO
		this.Awardable = isAwarded;
	}
	
	/**
	 * 设置邮箱
	 * 
	 * @param str
	 */
	public void setMail(String str)
	{
		// TODO
		this.mail = str;
	}
	
	/**
	 * 设置用户名
	 * 
	 * @param str
	 */
	public void setName(String str)
	{
		// TODO
		this.name = str;
	}
	
	/**
	 * 设置手机号码
	 * 
	 * @param str
	 */
	public void setPhone(String str)
	{
		// TODO
		this.phone = str;
	}
	
	/**
	 * 设置排名
	 * 
	 * @param r
	 */
	public void setRank(int r)
	{
		// TODO
		this.rank = r;
	}
	
	/**
	 * 设置成绩
	 * 
	 * @param num
	 */
	public void setScore(int num)
	{
		// TODO
		this.score = num;
	}
	
	private int			award		= 3;
	
	private boolean		Awardable	= true;
	
	private ImageItem	buttonNot;
	
	private ImageItem	buttonOk;
	
	private ImageItem	logo;
	
	private String		mail		= "454961617@qq.com";
	
	private String		name		= "张三";
	
	private String		phone		= "13450475911";
	
	private int			rank		= 3;
	
	private int			score		= 89;
	
}
